/******************************************************************************

	COPYRIGHT(C) JONAS 'SORTIE' TERMANSEN 2010.

	This file is part of the Maxsi Library.

	Maxsi Library is free software: you can redistribute it and/or modify it
	under the terms of the GNU Lesser General Public License as published by
	the Free Software Foundation, either version 3 of the License, or (at your
	option) any later version.

	Maxsi Library is distributed in the hope that it will be useful, but
	WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
	or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
	License for more details.

	You should have received a copy of the GNU Lesser General Public License
	along with Maxsi Library. If not, see <http://www.gnu.org/licenses/>.

	Maxsi Library
	A powerful Cross-Platform C++ General Purpose Library that allows you to
	efficiently create high-performance and reliable applications.

	MaxsiWindowGTK.h
	Implements the Maxsi Window System using GTK.

******************************************************************************/

#ifndef MaxsiWindowSystemGTK_H
#define MaxsiWindowSystemGTK_H

//=============================================================================
//	Include headers.
//=============================================================================
extern "C"
{
#include <gtk/gtk.h>
}

BeginMaxsiNamespace

//=============================================================================
//	Forward declarations.
//=============================================================================
class	MaxsiWindowGTK;
class	MaxsiWindowSystemGTK;

//=============================================================================
//	Define where the MaxsiWindowSystemGTK interface is declared.
//=============================================================================
#undef MAXSI_INTERFACE
#define MAXSI_INTERFACE MAXSI_INTERFACE_IMPLEMENTED_IN_MAXSI_LIBRARY

//=============================================================================
//	Declare the MaxsiWindowSystemGTK interface.
//=============================================================================
MAXSI_CLASSLINK MaxsiWindowSystemGTK : public MaxsiWindowSystem
{
	MAXSI_DECLARE_IMPLEMENTATION(MaxsiWindowSystemGTK, MaxsiWindowSystem, MAXSI_INTERFACE_STATIC);

public:
	MaxsiWindowSystemGTK();
	virtual ~MaxsiWindowSystemGTK();

public:
	MaxsiWindowEvent*	FirstEvent;
	MaxsiWindowEvent*	LastEvent;
	MaxsiHandle			EventLock;
	GSource*			TimerGTK;

public:
	virtual int Initialize(int* argc, char** argv[]) MAXSI_INTERFACE;
	virtual void ShutDown() MAXSI_INTERFACE;
	virtual int MainLoop() MAXSI_INTERFACE;
	virtual MaxsiWindow* CreateWindow(MaxsiWindow* Parent, MESTR* ClassName, int Width, int Height, int Left, int Top, MESTR* Title) MAXSI_INTERFACE;
	virtual void DeleteWindow(MaxsiWindow* Window) MAXSI_INTERFACE;
	virtual int MsgBox(MaxsiHandle Parent, int Flags, MESTR* Message, MESTR* Title) MAXSI_INTERFACE;
	virtual MaxsiError PostEventThreaded(MaxsiWindowEvent* Event) MAXSI_INTERFACE;
	virtual void OnEventTimer();
	
};

//=============================================================================
//	Define where the MaxsiControl interface is declared.
//=============================================================================
#undef MAXSI_INTERFACE
#define MAXSI_INTERFACE MAXSI_INTERFACE_IMPLEMENTED_IN_MAXSI_LIBRARY

//=============================================================================
//	Declare the MaxsiWindow interface.
//=============================================================================
MAXSI_CLASSLINK MaxsiWindowGTK : public MaxsiWindow
{
	MAXSI_DECLARE_IMPLEMENTATION(MaxsiWindowGTK, MaxsiWindow, MAXSI_INTERFACE_DYNAMIC);

public:
	MaxsiWindowGTK();
	virtual ~MaxsiWindowGTK();

public:
	GtkWidget*	WindowGTK;
	GtkWidget*	Frame;

public:
	virtual MaxsiError Initialize(MaxsiWindow* Parent, MESTR* ClassName, int Width, int Height, int Left, int Top, MESTR* Title) MAXSI_INTERFACE;
	virtual MaxsiError Destroy() MAXSI_INTERFACE;
	virtual MaxsiError Become(MaxsiWindow* NewSelf) MAXSI_INTERFACE;
	virtual MaxsiError OnEvent(MaxsiWindowEvent* Event) MAXSI_INTERFACE;
	virtual MaxsiError Show() MAXSI_INTERFACE;
	virtual MaxsiError Hide() MAXSI_INTERFACE;
	virtual void SetEventHandler(MaxsiWindowEventHandler Handler, BYTE* UserData) MAXSI_INTERFACE;
	virtual MaxsiWindow* CreateChild(MESTR* ClassName, int Width, int Height, int Left, int Top, MESTR* Title) MAXSI_INTERFACE;
	virtual MESTR* GetControlType() MAXSI_INTERFACE;
	virtual int Left() MAXSI_INTERFACE;
	virtual int Top() MAXSI_INTERFACE;
	virtual int Width() MAXSI_INTERFACE;
	virtual int Height() MAXSI_INTERFACE;
	virtual int Right() MAXSI_INTERFACE;
	virtual int Bottom() MAXSI_INTERFACE;
	virtual MaxsiError Move(int NewLeft, int NewTop, int NewWidth, int NewHeight) MAXSI_INTERFACE;
	virtual MaxsiError SetProgress(float Progress, int Type) MAXSI_INTERFACE;
	virtual MaxsiError SetText(MESTR* NewText) MAXSI_INTERFACE;
	virtual MaxsiError SetFont(MaxsiHandle NewFont) MAXSI_INTERFACE;
	virtual MESTR* GetText() MAXSI_INTERFACE;
	
};

//=============================================================================
//	Define where the following classes are defined.
//=============================================================================
#undef MAXSI_INTERFACE
#define MAXSI_INTERFACE MAXSI_INTERFACE_IMPLEMENTED_IN_MAXSI_LIBRARY

//=============================================================================
//	Declare the MaxsiBaseControlGTK interface.
//=============================================================================
MAXSI_CLASSLINK MaxsiBaseControlGTK : public MaxsiWindow
{
	MAXSI_DECLARE_CHILD_CLASS(MaxsiBaseControlGTK, MaxsiWindow);

public:
	MaxsiBaseControlGTK();
	virtual ~MaxsiBaseControlGTK();

public:
	GtkWidget*	WindowGTK;

public:
	virtual MaxsiError Destroy() MAXSI_INTERFACE;
	virtual MaxsiError OnEvent(MaxsiWindowEvent* Event) MAXSI_INTERFACE;
	virtual MaxsiError Show() MAXSI_INTERFACE;
	virtual MaxsiError Hide() MAXSI_INTERFACE;
	virtual void SetEventHandler(MaxsiWindowEventHandler Handler, BYTE* UserData) MAXSI_INTERFACE;
	virtual MaxsiWindow* CreateChild(MESTR* ClassName, int Width, int Height, int Left, int Top, MESTR* Title) MAXSI_INTERFACE;
	virtual int Left() MAXSI_INTERFACE;
	virtual int Top() MAXSI_INTERFACE;
	virtual int Width() MAXSI_INTERFACE;
	virtual int Height() MAXSI_INTERFACE;
	virtual int Right() MAXSI_INTERFACE;
	virtual int Bottom() MAXSI_INTERFACE;
	virtual MaxsiError Move(int NewLeft, int NewTop, int NewWidth, int NewHeight) MAXSI_INTERFACE;
	virtual MaxsiError SetProgress(float Progress, int Type) MAXSI_INTERFACE;
	virtual MaxsiError SetText(MESTR* NewText) MAXSI_INTERFACE;
	virtual MaxsiError SetFont(MaxsiHandle NewFont) MAXSI_INTERFACE;
	virtual MESTR* GetText() MAXSI_INTERFACE;
	
};

//=============================================================================
//	Declare the MaxsiButtonGTK interface.
//=============================================================================
MAXSI_CLASSLINK MaxsiButtonGTK : public MaxsiBaseControlGTK
{
	MAXSI_DECLARE_IMPLEMENTATION(MaxsiButtonGTK, MaxsiWindow, MAXSI_INTERFACE_DYNAMIC);

public:
	MaxsiButtonGTK();
	virtual ~MaxsiButtonGTK();

public:
	virtual MaxsiError Initialize(MaxsiWindow* Parent, MESTR* ClassName, int Width, int Height, int Left, int Top, MESTR* Title) MAXSI_INTERFACE;
	virtual MaxsiError Become(MaxsiWindow* NewSelf) MAXSI_INTERFACE;
	virtual MaxsiError SetText(MESTR* NewText) MAXSI_INTERFACE;
	virtual MaxsiError SetFont(MaxsiHandle NewFont) MAXSI_INTERFACE;
	virtual MESTR* GetControlType() MAXSI_INTERFACE;
	
};

//=============================================================================
//	Declare the MaxsiTextSingleLineGTK interface.
//=============================================================================
MAXSI_CLASSLINK MaxsiTextSingleLineGTK : public MaxsiBaseControlGTK
{
	MAXSI_DECLARE_IMPLEMENTATION(MaxsiTextSingleLineGTK, MaxsiWindow, MAXSI_INTERFACE_DYNAMIC);

public:
	MaxsiTextSingleLineGTK();
	virtual ~MaxsiTextSingleLineGTK();

public:
	virtual MaxsiError Initialize(MaxsiWindow* Parent, MESTR* ClassName, int Width, int Height, int Left, int Top, MESTR* Title) MAXSI_INTERFACE;
	virtual MaxsiError Become(MaxsiWindow* NewSelf) MAXSI_INTERFACE;
	virtual MaxsiError SetText(MESTR* NewText) MAXSI_INTERFACE;
	virtual MaxsiError SetFont(MaxsiHandle NewFont) MAXSI_INTERFACE;
	virtual MESTR* GetText() MAXSI_INTERFACE;
	virtual MESTR* GetControlType() MAXSI_INTERFACE;
	
};

//=============================================================================
//	Declare the MaxsiLabelGTK interface.
//=============================================================================
MAXSI_CLASSLINK MaxsiLabelGTK : public MaxsiBaseControlGTK
{
	MAXSI_DECLARE_IMPLEMENTATION(MaxsiLabelGTK, MaxsiWindow, MAXSI_INTERFACE_DYNAMIC);

public:
	MaxsiLabelGTK();
	virtual ~MaxsiLabelGTK();

public:
	virtual MaxsiError Initialize(MaxsiWindow* Parent, MESTR* ClassName, int Width, int Height, int Left, int Top, MESTR* Title) MAXSI_INTERFACE;
	virtual MaxsiError Become(MaxsiWindow* NewSelf) MAXSI_INTERFACE;
	virtual MaxsiError SetText(MESTR* NewText) MAXSI_INTERFACE;
	virtual MaxsiError SetFont(MaxsiHandle NewFont) MAXSI_INTERFACE;
	virtual MESTR* GetControlType() MAXSI_INTERFACE;
	
};

//=============================================================================
//	Declare the MaxsiProgressBarGTK interface.
//=============================================================================
MAXSI_CLASSLINK MaxsiProgressBarGTK : public MaxsiBaseControlGTK
{
	MAXSI_DECLARE_IMPLEMENTATION(MaxsiProgressBarGTK, MaxsiWindow, MAXSI_INTERFACE_DYNAMIC);

public:
	MaxsiProgressBarGTK();
	virtual ~MaxsiProgressBarGTK();

public:
	float	CurrentProgress;
	int		CurrentProgressType;

public:
	virtual MaxsiError Initialize(MaxsiWindow* Parent, MESTR* ClassName, int Width, int Height, int Left, int Top, MESTR* Title) MAXSI_INTERFACE;
	virtual MaxsiError Become(MaxsiWindow* NewSelf) MAXSI_INTERFACE;
	virtual MaxsiError SetProgress(float Progress, int Type) MAXSI_INTERFACE;
	virtual MESTR* GetControlType() MAXSI_INTERFACE;
	
};

MAXSI_LINK int CriticalMsgBox(MaxsiHandle Parent, int Flags, MESTR* ErrorMessage, MESTR* ErrorTitle);

EndMaxsiNamespace

#endif
